package com.cj.controller;

import com.cj.Service.LogService;
import com.cj.pojo.LogPojo;
import com.cj.vo.JsonResult;
import com.cj.vo.LogPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/log/")
public class LogController {

    @Autowired
    LogService logService;

    // 页面返回
    @RequestMapping("index")
    public String index(){
        return "pages/content/log_list";
    }

    // 分页显示列表
    @RequestMapping("page")
    @ResponseBody
    public JsonResult queryLogPage(LogPageVo logPageVo){
        List<LogPojo> list = logService.queryLogPage(logPageVo);
        return new JsonResult(1,"成功",list );
    }
    // 分页显示列表
    @RequestMapping("count")
    @ResponseBody
    public JsonResult countLog(LogPojo logPojo ){
        Integer countLog = (logService.countLog(logPojo)-1)/15+1;
        return new JsonResult(1,"成功",countLog );
    }

    // 批量删除
    @RequestMapping("delete")
    @ResponseBody
    public JsonResult deleteLogs(Integer[] ids){
        logService.deleteLogs(ids);
        return new JsonResult(1,"成功",null );
    }

}
